var months = new Array("4月","5月","6月","7月","8月","9月","10月","11月","12月","来年\n1月","来年\n2月","来年\n3月");
var currentYearTotalData = new Array("0","0","0","0","0","0","0","0","0","0","0","0");
var zeroCurrentYearTotalData = new Array("0","0","0","0","0","0","0","0","0","0","0","0");
var currentYearMaxData = new Array("0","0","0","0","0","0","0","0","0","0","0","0");
var zeroCurrentYearMaxData = new Array("0","0","0","0","0","0","0","0","0","0","0","0");
var pastYearTotalData = new Array("0","0","0","0","0","0","0","0","0","0","0","0");
var zeroPastYearTotalData = new Array("0","0","0","0","0","0","0","0","0","0","0","0");
var pastYearMaxData = new Array("0","0","0","0","0","0","0","0","0","0","0","0");
var zeroPastYearMaxData = new Array("0","0","0","0","0","0","0","0","0","0","0","0");



    var storeStatistic = new Ext.data.JsonStore({
    fields: ['name', 'Current_Year_Total', 'Current_Year_Max','Past_Year_Total','Past_Year_Max'],
    //data: data.
});



////////////////////////////////statistic view data handle //////////////////////////////////////////////////////

function storeCurrentYearStatisticsData(v){
	
	currentYearTotalData = zeroCurrentYearTotalData.slice(0);
	currentYearMaxData = zeroCurrentYearMaxData.slice(0);

	for(var i=0; i<v.response.tap_list.length; i++){
		for(var j=0; j<v.response.tap_list[i].data_list[0].amount_electric_power.length;j++){
			
			if(parseFloat(currentYearMaxData[j]) < parseFloat(v.response.tap_list[i].data_list[0].amount_electric_power[j])){
				currentYearMaxData[j] = parseFloat(((parseFloat(v.response.tap_list[i].data_list[0].amount_electric_power[j]))/1000).toFixed(3));
			}
			
			currentYearTotalData[j]=parseFloat((parseFloat(currentYearTotalData[j])+ (v.response.tap_list[i].data_list[0].amount_electric_power[j])/1000).toFixed(3));
			
			//currentYearTotalData[j] = parseFloat(currentYearTotalData[j]).toFixed(3);
		}
	}
 }

function storePastYearStatisticsData(v){

	var data = [];
	pastYearTotalData = zeroPastYearTotalData.slice(0);
	pastYearMaxData = zeroPastYearMaxData.slice(0);

	for(var i=0; i<v.response.tap_list.length; i++){
		for(var j=0; j<v.response.tap_list[i].data_list[0].amount_electric_power.length;j++){
			
			 if(parseFloat(pastYearMaxData[j]) < parseFloat(v.response.tap_list[i].data_list[0].amount_electric_power[j])){
			 	pastYearMaxData[j] = parseFloat(((parseFloat(v.response.tap_list[i].data_list[0].amount_electric_power[j]))/1000).toFixed(3));
			 }
			
			pastYearTotalData[j]=parseFloat((parseFloat(pastYearTotalData[j])+(v.response.tap_list[i].data_list[0].amount_electric_power[j])/1000).toFixed(3));
			//pastYearTotalData[j] = parseFloat(pastYearTotalData[j]).toFixed(3);
		}
	}
	
    for (var i = 0; i < 12; i++) {
    	//alert(pastYearTotalData[i]);
    	data.push({name : months[i], Current_Year_Total : currentYearTotalData[i], Current_Year_Max : currentYearMaxData[i], Past_Year_Total : pastYearTotalData[i], Past_Year_Max : pastYearMaxData[i]});
    	//data.push({name : aa[i], Past_Year_Total : pastYearTotalData[i], Past_Year_Max : pastYearMaxData[i]});

    }
    

    storeStatistic.loadData(data,false);
//	alert(storeStatistic.getAt(0).get('Current_Year_Max'));
}

